<div class="bg-light lter b-b wrapper-md ng-scope">
    <h4 class="m-n font-thin">会员卡设置</h4>
    <button ui-sref="app.memberCard" class="btn-back btn btn-dark btn-sm btn-rounded">
        返回
    </button>
</div>
<div class="wrapper" ng-controller="memberCardAddCtrl">
    <div class="panel panel-default">
        <div class="panel-heading m-n">
            添加会员卡信息
        </div>
        <div class="panel-body">
            <div class="panel-default panel-body">
                <form name="memberInfo" class="form-horizontal form-validation" ng-submit="addCards()">
                    <div class="form-group bg-light">
                        <div class="panel-body bg-light">
                            <label class="col-sm-2 text-right m-n font-bold">会员卡基本信息</label>
                            <i class="fa fa-question-circle text-muted h6" popover-placement="top" popover="会员基本信息所需必要的信息" popover-trigger="mouseenter">
                            </i>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label font-bold">会员卡名称</label>
                        <div class="col-sm-5">
                            <input type="text" ng-model="memberCard.cardName" name="cardName" class="form-control" placeholder="请输入会员卡名称" required>
                        </div>
                        <div class="col-sm-5 form-text" ng-if="memberInfo.cardName.$touched">
                            <span class="text-danger" ng-if="memberInfo.cardName.$error.required">会员卡名称是必填的</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label font-bold">会员卡权益</label>
                        <div class="col-sm-5">
                            <div class="m-b-xs">
                                <label class="i-checks i-checks-sm m-b-none h6">
                                    <input type="checkbox" ng-checked="memberCard.isFreeCarriage==1" ng-click=" memberCard.isFreeCarriage= memberCard.isFreeCarriage==1?0:1;"><i></i>
                                </label>
                                <div class="inline">
                                    <p class="inline">免运费</p>
                                </div>
                            </div>
                            <div class="m-b-xs">
                                <div class="inline">
                                    <label class="i-checks i-checks-sm m-b-none h6">
                                        <input type="checkbox" ng-checked=" memberCard.isDiscount==1" ng-click=" memberCard.isDiscount= memberCard.isDiscount==1?0:1;"><i></i>
                                    </label>
                                    <p class="inline m-r-xs">会员折扣</p>
                                </div>
                                <div class="inline" ng-if=" memberCard.isDiscount==1">
                                    <input type="number" min="1" max="10" step="0.01" class="inline w-xs form-control m-r-xs" name="discount" ng-model=" memberCard.discount" required>
                                    <p class="inline m-n">折</p>
                                </div>
                                <div class="form-text" ng-if="memberInfo.discount.$touched">
                                    <span class="text-danger" ng-if="memberInfo.discount.$error.required">(折扣是必须填的)</span>
                                </div>
                            </div>
                            <div>
                                <label class="i-checks i-checks-sm m-b-none h6">
                                    <input type="checkbox" ng-checked=" memberCard.isPresentCoupon==1" ng-click=" memberCard.isPresentCoupon= memberCard.isPresentCoupon==1?0:1;"><i></i>
                                </label>
                                <p class="inline m-r-xs">开卡赠送优惠卷</p>
                                <div class="inline" ng-if=" memberCard.isPresentCoupon==1">
                                    <select class="form-control w-sm inline m-r-xs" name="coupons" ng-model="memberCard.couponsId" required>
                                        <option value="">请选择优惠卷</option>
                                        <option ng-repeat="c in couponsList" value="{{c.id}}" >{{c.name}}</option>
                                    </select>

                                    <div class="inline">
                                        <!--<input type="number" min="1" step="1" class="inline w-xs form-control m-r-xs" name="couponsCount" ng-model="memberCard.couponsCount" required>-->
                                        <!--<p class="inline m-n">张</p>-->
                                        <div class="form-text pull-right" ng-if="memberInfo.coupons.$touched">
                                            <span class="text-danger" ng-if="memberInfo.coupons.$error.required">(请您选择赠送的优惠券)</span>
                                        </div>
                                        <!--<div class="form-text pull-right" ng-if="memberInfo.couponsCount.$touched">-->
                                            <!--<span class="text-danger" ng-if="memberInfo.couponsCount.$error.required">(请您填写赠送优惠券数量)</span>-->
                                        <!--</div>-->
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label font-bold">有效日期</label>
                        <div class="col-sm-5">
                            <div class="m-b-xs">
                                <div>
                                    <div class="m-b-sm m-r-xs">
                                        <div class="radio inline m-r-n">
                                            <label class="i-checks i-checks-sm">
                                                <input type="radio" checked="checked" name="memberCardValidTimeType"  ng-model="memberCard.validTimeState" value="0">
                                                <i></i>
                                            </label>
                                        </div>
                                        <p class="inline m-n">永久有效</p>
                                    </div>
                                    <div class="m-b-sm">
                                        <div class="radio inline m-r-n">
                                            <label class="i-checks i-checks-sm">
                                                <input type="radio" name="memberCardValidTimeType" ng-model="memberCard.validTimeState" value="1">
                                                <i></i>
                                            </label>
                                        </div>
                                        <p class="inline m-n">固定日期</p>
                                    </div>
                                </div>
                                <div class="m-b-xs" ng-if=" memberCard.validTimeState==1">
                                    <div class="inline" ng-controller="DatepickerDemoCtrl">
                                        <div class="input-group w-lg">
                                            <input type="text" class="form-control" placeholder="请输入开始日期" alt-input-formats="altInputFormats" uib-datepicker-popup="yyyy-MM-dd" datepicker-popup="yyyy/MM/dd" ng-model="memberCard.validStartTime"
                                                   alt-input-formats="altInputFormats" is-open="opened" datepicker-options="dateOptions" ng-required="true" close-text="关闭" clear-text="清空" current-text="今天"/>
                                                <span class="input-group-btn">
                                                    <button type="button" class="btn btn-default" ng-click="open($event)"><i class="glyphicon glyphicon-calendar"></i></button>
                                                </span>
                                        </div>
                                    </div>
                                    <div class="inline" ng-controller="DatepickerDemoCtrl">
                                        <div class="input-group w-lg">
                                            <input type="text" class="form-control" placeholder="请输入结束日期" alt-input-formats="altInputFormats" uib-datepicker-popup="yyyy-MM-dd" datepicker-popup="yyyy/MM/dd" ng-model="memberCard.validEndTime"
                                                   alt-input-formats="altInputFormats" is-open="opened" datepicker-options="dateOptions" ng-required="true" close-text="关闭" clear-text="清空" current-text="今天"/>
                                                <span class="input-group-btn">
                                                    <button type="button" class="btn btn-default" ng-click="open($event)"><i class="glyphicon glyphicon-calendar"></i></button>
                                                </span>
                                        </div>
                                    </div>
                                    <div class="form-text pull-right" ng-if="memberCard.validStartTime >= memberCard.validEndTime">
                                        <span class="text-danger" >(请正确选择有效时间)</span>
                                    </div>
                                </div>
                            </div>
                            <div>
                                <div class="m-b-sm m-r-xs">
                                    <div class="radio inline m-r-n">
                                        <label class="i-checks i-checks-sm">
                                            <input type="radio" name="memberCardValidTimeType"  ng-model="memberCard.validTimeState" value="2">
                                            <i></i>
                                        </label>
                                    </div>
                                    <p class="inline m-n">从当天领取开始N天内有效</p>
                                </div>
                                <div ng-if=" memberCard.validTimeState==2">
                                    <p class="inline m-r-xs">从当天领取开始</p>
                                    <input type="number" min="1" class="inline w-xs form-control m-r-xs" name="memberCardValidDays" ng-model="memberCard.validDays">
                                    <p class="inline m-r-xs">天内有效</p>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label font-bold">使用须知</label>
                        <div class="col-sm-5">
                            <textarea class="form-control" name="instruction" rows="5" ng-model="memberCard.instruction" placeholder="会员特权会根据您上文的勾选情况系统自动生成，此处可填写其它补充信息以便会员知晓，最多可输入300个字符" required></textarea>
                        </div>
                        <div class="form-text" ng-if="memberInfo.instruction.$touched">
                            <span class="text-danger" ng-if="memberInfo.instruction.$error.required">使用须知是必须填的</span>
                        </div>
                    </div>
                    <div ng-if="memberCard.type==1">
                        <div class="form-group" >
                            <div class="panel-body bg-light">
                                <label class="col-sm-2 text-right m-n font-bold">会员卡领取条件</label>
                                <i class="fa fa-question-circle text-muted h6" popover-placement="top" popover="会员卡领取条件所需必要的条件" popover-trigger="mouseenter">
                                </i>
                                <label class="text-info m-l-xs">(请至少选择一项领取条件)</label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label font-bold">领取条件</label>
                            <div class="col-sm-5">
                                <div class="m-b-xs">
                                    <div class="inline">
                                        <label class="i-checks i-checks-sm m-b-none h6">
                                            <input type="checkbox" ng-checked=" memberCard.isOpenBuyCount==1" ng-click=" memberCard.isOpenBuyCount= memberCard.isOpenBuyCount==1?0:1;"><i></i>
                                        </label>
                                        <p class="inline m-t-sm m-r-xs">累计支付</p>
                                    </div>
                                    <div class="inline" ng-if=" memberCard.isOpenBuyCount==1">
                                        <input type="number" min="{{maxCard.buyCount+1}}" step="1" class="inline w-xs form-control m-r-xs" name="buyCount" ng-model=" memberCard.buyCount" required>
                                        <p class="inline m-n">笔</p>
                                    </div>
                                    <div class="form-text" ng-if="memberInfo.buyCount.$touched">
                                        <span class="text-danger" ng-if="memberInfo.buyCount.$error.required">(笔数是必须填的)</span>
                                        <span class="text-danger" ng-if="memberInfo.buyCount.$error.min">(请填写大于最小值的值)</span>
                                    </div>
                                </div>
                                <div class="m-b-xs">
                                    <div class="inline">
                                        <label class="i-checks i-checks-sm m-b-none h6">
                                            <input type="checkbox" ng-checked=" memberCard.isOpenConsumePrice==1" ng-click=" memberCard.isOpenConsumePrice= memberCard.isOpenConsumePrice==1?0:1;"><i></i>
                                        </label>
                                        <p class="inline m-t-sm m-r-xs">累计消费</p>
                                    </div>
                                    <div class="inline" ng-if=" memberCard.isOpenConsumePrice==1">
                                        <input type="number" min="{{maxCard.consumePrice+0.01}}" step="0.01" class="inline w-xs form-control m-r-xs" name="consumePrice" ng-model=" memberCard.consumePrice" required>
                                        <p class="inline m-n">元</p>
                                    </div>
                                    <div class="form-text" ng-if="memberInfo.consumePrice.$touched">
                                        <span class="text-danger" ng-if="memberInfo.consumePrice.$error.required">(金额是必须填的)</span>
                                        <span class="text-danger" ng-if="memberInfo.consumePrice.$error.min">(请填写大于最小值的值)</span>
                                    </div>
                                </div>
                                <!--<div class="m-b-xs">-->
                                    <!--<div class="inline">-->
                                        <!--<label class="i-checks i-checks-sm m-b-none h6">-->
                                            <!--<input type="checkbox" ng-checked=" memberCard.isOpenConsumeIntegral==1" ng-click=" memberCard.isOpenConsumeIntegral= memberCard.isOpenConsumeIntegral==1?0:1;"><i></i>-->
                                        <!--</label>-->
                                        <!--<p class="inline m-t-sm m-r-xs">累计积分</p>-->
                                    <!--</div>-->
                                    <!--<div class="inline" ng-if=" memberCard.isOpenConsumeIntegral==1">-->
                                        <!--<input type="number" min="{{maxCard.consumeIntegral+1}}" step="1" class="inline w-xs form-control m-r-xs" name="consumeIntegral" ng-model=" memberCard.consumeIntegral" required>-->
                                        <!--<p class="inline m-n">分</p>-->
                                    <!--</div>-->
                                    <!--<div class="form-text" ng-if="memberInfo.consumeIntegral.$touched">-->
                                        <!--<span class="text-danger" ng-if="memberInfo.consumeIntegral.$error.required">(分值是必须填的)</span>-->
                                        <!--<span class="text-danger" ng-if="memberInfo.consumeIntegral.$error.min">(请填写大于最小值的值)</span>-->
                                    <!--</div>-->
                                <!--</div>-->
                            </div>
                        </div>
                    </div>
                    <div class="form-group" ng-if="memberCard.type==2">
                        <label class="col-sm-2 control-label font-bold">会员卡售价</label>
                        <div class="col-sm-5">
                            <div class="m-b-xs">
                                <div class="inline">
                                    <p class="inline m-r-xs">金额</p>
                                    <input type="number" min="0" name="price" ng-model="memberCard.price" step="0.01" ng-pattern="/^[0-9]+(.[0-9]{1,2})?$/" class="form-control w-xs inline m-r-xs" required>
                                    <p class="inline">元</p>
                                    <div class="form-text pull-right" ng-if="memberInfo.price.$touched">
                                        <span class="text-danger" ng-if="memberInfo.price.$error.required">(请您填写会员卡金额)</span>
                                        <span class="text-danger" ng-if="memberInfo.price.$error.pattern">金额最多保留两位小数</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!--<div class="form-group">-->
                        <!--<label class="col-sm-2 control-label font-bold">是否需要激活</label>-->
                        <!--<div class="col-sm-5">-->
                            <!--<div class="inline">-->
                                <!--<div class="m-b-sm m-r-xs inline">-->
                                    <!--<div class="radio inline m-r-n">-->
                                        <!--<label class="i-checks i-checks-sm">-->
                                            <!--<input name="activation" type="radio" checked="checked" ng-model="memberCard.activationState" value="0">-->
                                            <!--<i></i>-->
                                        <!--</label>-->
                                    <!--</div>-->
                                    <!--<p class="inline m-n">无需激活</p>-->
                                <!--</div>-->
                                <!--<div class="m-b-sm m-r-xs inline">-->
                                    <!--<div class="radio inline m-r-n">-->
                                        <!--<label class="i-checks i-checks-sm">-->
                                            <!--<input name="activation"  type="radio" ng-model="memberCard.activationState" value="1">-->
                                            <!--<i></i>-->
                                        <!--</label>-->
                                    <!--</div>-->
                                    <!--<p class="inline m-n">需要激活</p>-->
                                <!--</div>-->
                            <!--</div>-->
                        <!--</div>-->
                    <!--</div>-->
                    <!--<div class="form-group" ng-if=" memberCard.activationState==1">-->
                        <!--<label class="col-sm-2 control-label font-bold">激活方式</label>-->
                        <!--<div class="col-sm-5">-->
                            <!--<div class="inline">-->
                                <!--<div class="checkbox m-r-xs inline">-->
                                    <!--<label class="i-checks i-checks-sm ">-->
                                        <!--<input type="checkbox" ng-checked=" memberCard.isPhoneVerification==1"-->
                                               <!--ng-click="memberCard.isPhoneVerification=memberCard.isPhoneVerification==1?0:1;" ><i></i>-->
                                    <!--</label>-->
                                    <!--<div class="inline">-->
                                        <!--<p class="inline m-n">开启手机验证码激活</p>-->
                                    <!--</div>-->
                                <!--</div>-->
                                <!--<div class="checkbox m-r-xs inline">-->
                                    <!--<label class="i-checks i-checks-sm m-b-none h6">-->
                                        <!--<input type="checkbox" ng-checked=" memberCard.isPerfectMessage==1"-->
                                               <!--ng-click="memberCard.isPerfectMessage=memberCard.isPerfectMessage==1?0:1;"><i></i>-->
                                    <!--</label>-->
                                    <!--<div class="inline">-->
                                        <!--<p class="inline m-n">完善会员信息</p>-->
                                    <!--</div>-->
                                <!--</div>-->
                            <!--</div>-->
                        <!--</div>-->
                    <!--</div>-->
                    <div class="form-group">
                        <div class="col-sm-4 col-sm-offset-2">
                            <button type="submit" class="btn btn-success"
                                    ng-disabled="memberInfo.$invalid ||
                                    (memberCard.isOpenConsumeIntegral==0 && memberCard.isOpenConsumePrice==0 && memberCard.isOpenBuyCount==0 && memberCard.type==1)">保存</button>
                                    <!--((memberCard.isPhoneVerification==0 && memberCard.isPerfectMessage==0) && memberCard.activationState != 0) ||-->
                        </div>
                    </div>

                </form>
            </div>
        </div>
    </div>

</div>